import { get, post } from '@/utils/https';
import { getOper } from '@/modules/index/src/common/tools';
const loginOrg = getOper().c_login_dept_code; // 当前登录机构
// console.log('getOper=》》》》》》》》》》', getOper().c_oper_code);
// 未级联机构下拉（应用场景: 查询页面使用）
export function getOrgOptionAPi(arg = loginOrg) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/dict/agency/institution',
      {
        'code': arg
      },
      res => {
        resolve(res);
      },
      err => {
				resolve(err);
      }
    );
  });
}
// 管理区编码
export function getRegionCode(data) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/dict/agency/djkregion',
    {
      code: data
    },
      res => {
        resolve(res);
      },
      err => {
        resolve(err);
      }
    );
  });
}
// 营业区下拉options
// /dict/agency/region 旧
// /dict/agency/region_all 新
export function getRegionOptionAPi(arg = loginOrg) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/dict/agency/region_all',
      {
        'code': arg
      },
      res => {
        resolve(res);
      },
      err => {
				resolve(err);
      }
    );
  });
}
// 营业部下拉options
// /dict/agency/dept 旧
// /dict/agency/dept_all 新
export function getDeptOptionAPi(arg = loginOrg) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/dict/agency/dept_all',
      {
        'code': arg
      },
      res => {
        resolve(res);
      },
      err => {
				resolve(err);
      }
    );
  });
}
// 核心接口补偿推送
export function compensationTest(data) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/lasynccorelog/compensationtest',
    data,
      res => {
        resolve(res);
      },
      err => {
        resolve(err);
      }
    );
  });
}
// 日志推送
export function getLog(data) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/lasynccorelog/getlog',
      data,
      res => {
        resolve(res);
      },
      err => {
        resolve(err);
      }
    );
  });
}
// 查询代理人
export function getAgencyAPi(data) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/tbagentinfo/get_recommended_page',
      {
        parentCode: data
      },
      res => {
        resolve(res);
      },
      err => {
				resolve(err);
      }
    );
  });
}
// 删除
export function deletePersonAPi(data) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/tbagentinfo/delete_personnelinformationids',
      {
        deletes: data
      },
      res => {
        resolve(res);
				Message.success({ message: res.message, duration: 2000 });
      },
      err => {
				resolve(err);
      }
    );
  });
}
// 获取新增人员流水号
export function getApprovalIdApi(data) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/tbagentinfo/query_approvalid',
      {
        ids: data
      },
      res => {
        resolve(res);
      },
      err => {
				resolve(err);
      }
    );
  });
}

/*
获取普通下拉字典数据通用接口  type如下：
	agentState: 代理人状态 1:在职  4:离职
	endFlag: 停业标识 Y-停业 N-开业
	trainPassFlag:  培训状态 0-通过 1-不通过
	polityVisage: 政治面貌 0-群众 1-党员 2-团员
	state: 资格证书状态 0-有效 1-即将失效 2-失效
	degree:学历 0-博士 1-硕士 2-本科 3-专科 4-高中 5-初中 6-小学
	sex: 性别 0-男 1-女
	insideFlag:  内勤标志 0-内勤 1-外勤
	hobby: 是否独立代理人 N-否 Y-是
	marriage: 婚姻状态 0-未婚 1-已婚
	idx: 资格证类型 11-执业证
	nationality: 民族
	branchLevel: 销售机构级别 4-区 5-部
	suretyType: 担保人类型
	documentType: 证件类型 0-身份证
	contractType: 合同类型 0-代理制
	personnelStatus: 人员状态 0-待入职 1-在职 2	离职
	onTheJobType: 在职类型 0-新入职 1-二次入司 2	跨渠道二次入司
	personnelType: 人员类型 0-内部人员	1-外勤人员
	isFullTime: 是否专职 0-专职	1-兼职
	isOrNo: 是或否（是否隶属农村营销员，是否退伍军人）0-是 1-否
	relationship: 关系类型 0-父母 1-子女 2-配偶 3-本人
	rank: 职级 HXF0201-资源精英代理人 HXF0202-业务精英代理人
	approvalStatus: 审核状态 0-通过 1-未通过 2-审核中
	establishedType：销售机构页面：成立类型
	subjection：与上级隶属关系
	branchLevel： 销售机构级别
*/
export function getDictOptionsApi(data, code = '', parentCode) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/dict/constant',
      {
        type: data,
				code: code,
        parentCode: parentCode
      },
      res => {
        resolve(res);
      },
      err => {
				resolve(err);
      }
    );
  });
}

// 根据登录机构查询管理机构
export function getOrgListByCodeApi(code = getOper().c_login_dept_code) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/dict/agency/level',
      {
        type: 'subsidiaryCompany',
				code: code
      },
      res => {
        resolve(res);
      },
      err => {
				resolve(err);
      }
    );
  });
}

// 根据四级机构代码查询上一级所以机构代码 /sell/agency/info/search/enable/region
export function getRegionByAgencyCodeApi(code) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/sell/agency/info/search/enable/region',
    // post(PERFORM_URL + '/dict/agency/region',
      {
        type: 'subsidiaryCompany',
				code: code
      },
      res => {
        resolve(res);
      },
      err => {
				resolve(err);
      }
    );
  });
}
// 级联机构
export function getOrgListApi() {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/dict/constant',
      {
        type: 'subsidiaryCompany'
      },
      res => {
        resolve(res);
      },
      err => {
				resolve(err);
      }
    );
  });
}
// 级联机构
export function getCurrentOrgListApi(paramCode) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/dict/constant',
      {
        type: 'subsidiaryCompany',
				parentCode: paramCode
      },
      res => {
        resolve(res);
      },
      err => {
				resolve(err);
      }
    );
  });
}
// 级联 获取营业区
export function getRegionListApi(paramCode) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/dict/constant',
      {
        type: 'agencyRegion',
        parentCode: paramCode
      },
      res => {
        resolve(res);
      },
      err => {
				resolve(err);
      }
    );
  });
}
// 级联 获取营业部
export function getDepartmentListApi(paramCode) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/dict/constant',
      {
        type: 'agencyDepartment',
        parentCode: paramCode
      },
      res => {
        resolve(res);
      },
      err => {
				resolve(err);
      }
    );
  });
}
// 级联 省
export function getProvinceOptionsApi(paramCode) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/dict/constant',
      {
        type: 'bankProvince',
      },
      res => {
        resolve(res);
      },
      err => {
				resolve(err);
      }
    );
  });
}
// 级联 市
export function getCityOptionsApi(paramCode) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/dict/constant',
      {
        type: 'bankCity',
        parentCode: paramCode
      },
      res => {
        resolve(res);
      },
      err => {
				resolve(err);
      }
    );
  });
}
// 级联 县(后端未完成)
export function getCountyOptionsApi(paramCode) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/dict/constant',
      {
        type: 'bankProvince',
        parentCode: paramCode
      },
      res => {
        resolve(res);
      },
      err => {
				resolve(err);
      }
    );
  });
}
// 文件删除
export function removeFile(id, url) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/file/sftp/remove',
      {
        id,
				url
      },
      res => {
        resolve(res);
      },
      err => {
				resolve(err);
      }
    );
  });
}
// 执业机构
export function getpracticearea(agencyCode) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/tbagentinfo/getpracticearea',
      {
        agencyCode,
      },
      res => {
        resolve(res);
      },
      err => {
				resolve(err);
      }
    );
  });
}
// 判断电话号码是否重复
export function phoneIsSame(agentPhone) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/tbagentinfo/check_phone_number',
      {
        agentPhone,
      },
      res => {
        resolve(res);
      },
      err => {
				resolve(err);
      }
    );
  });
}
// 判断银行账号是否重复,不要管路径后端偷懒
export function isSamebankAccount(bankAccount) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/tbagentinfo/check_phone_number',
      {
        bankAccount,
      },
      res => {
        resolve(res);
      },
      err => {
				resolve(err);
      }
    );
  });
}
// 判断是否整是否相同
export function identityCardSameValid(num) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/agentinfo/query_onthejobtype',
      {
        certificateNum: num
      },
      res => {
        resolve(res);
      },
      err => {
				resolve(err);
      }
    );
  });
}
// 业务员职级下拉选接口
export function getAgentApi(num, arg = loginOrg) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/plus/deduction/agent',
      {
        ...num,
        code: arg,
      },
      res => {
        resolve(res);
      },
      err => {
				resolve(err);
      }
    );
  });
}
// 资格证证号重复校验
export function certificationCodeSameValid(num, agentCode = '') {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/tbagentinfo/check_certificationtype',
      {
        certificationCode: num,
				agentCode: agentCode
      },
      res => {
        resolve(res);
      },
      err => {
				resolve(err);
      }
    );
  });
}
// 管理机构下拉选接口  总公司、所有的分公司的代码+名称，根据登录机构权限进行显示
export function getGetallagencycodeApi(data = loginOrg) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/sele/getheadofficeandbranchoffice',
      {
        code: data
      },
      res => {
        resolve(res);
      },
      err => {
        resolve(err);
      }
    );
  });
}
// 管理机构下拉选  所有的分公司，根据登录机构权限进行显示
export function getGetbranchofficeApi(data = loginOrg) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/sele/getbranchoffice',
      {
        code: data
      },
      res => {
        resolve(res);
      },
      err => {
        resolve(err);
      }
    );
  });
}
// 管理机构下拉选  总公司、所有的分公司、支公司和营服部的代码+名称，根据登录机构权限进行显示
export function getAgencycodeApi(data = loginOrg) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/sele/getallagencycode',
      {
        code: data
      },
      res => {
        resolve(res);
      },
      err => {
        resolve(err);
      }
    );
  });
}
// 管理机构下拉选  总公司、所有的分公司、支公司和营服部的代码+名称，根据登录机构权限进行显示
export function getonetothreeagencycodeApi(data = loginOrg) {
  return new Promise((resolve, reject) => {
    post(PERFORM_URL + '/sele/getonetothreeagencycode',
      {
        code: data
      },
      res => {
        resolve(res);
      },
      err => {
        resolve(err);
      }
    );
  });
}
